import { cn } from '@/src/lib/utils'
import { z } from 'zod'

const dependentSchema = z.object({
  stars: z.number(),
  owner: z.string(),
  name: z.string(),
  pkg: z.string(),
  avatarURL: z.string(),
  version: z.string().nullable(),
  createdAt: z.string().transform(date => new Date(date))
})
type Dependent = z.infer<typeof dependentSchema>

export async function fetchDependents() {
  const data = await fetch('https://dependents.47ng.com', {
    next: {
      revalidate: 86_400 // 24 hours
    }
  }).then(res => res.json())
  return z.array(dependentSchema).parse(data)
}

export function DependentsSection() {
  return (
    <section className="container space-y-16">
      <h2 className="text-center text-3xl font-bold tracking-tighter md:text-4xl xl:text-5xl dark:text-white">
        Used by
      </h2>
      <SponsoredUsedBy />
      <DependentsLeaderboard />
    </section>
  )
}

function SponsoredUsedBy() {
  return (
    <p className="flex flex-wrap items-center justify-center gap-x-16 gap-y-8">
      <a href="https://vercel.com">
        <svg
          aria-label="Vercel"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 284 65"
          className="inline h-8 fill-black dark:fill-white"
        >
          <path d="M141.68 16.25c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zm117.14-14.5c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zm-39.03 3.5c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9v-46h9zM37.59.25l36.95 64H.64l36.95-64zm92.38 5l-27.71 48-27.71-48h10.39l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10v14.8h-9v-34h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" />
        </svg>
      </a>
      <a href="https://unkey.com">
        <svg
          aria-label="Unkey"
          xmlns="http://www.w3.org/2000/svg"
          width="93"
          height="40"
          viewBox="0 0 93 40"
        >
          <path
            d="M10.8 30.3C4.8 30.3 1.38 27.12 1.38 21.66V9.9H4.59V21.45C4.59 25.5 6.39 27.18 10.8 27.18C15.21 27.18 17.01 25.5 17.01 21.45V9.9H20.25V21.66C20.25 27.12 16.83 30.3 10.8 30.3ZM26.3611 30H23.1211V15.09H26.0911V19.71H26.3011C26.7511 17.19 28.7311 14.79 32.5111 14.79C36.6511 14.79 38.6911 17.58 38.6911 21.03V30H35.4511V21.9C35.4511 19.11 34.1911 17.7 31.1011 17.7C27.8311 17.7 26.3611 19.38 26.3611 22.62V30ZM44.8181 30H41.5781V9.9H44.8181V21H49.0781L53.5481 15.09H57.3281L51.7181 22.26L57.2981 30H53.4881L49.0781 23.91H44.8181V30ZM66.4219 30.3C61.5319 30.3 58.3219 27.54 58.3219 22.56C58.3219 17.91 61.5019 14.79 66.3619 14.79C70.9819 14.79 74.1319 17.34 74.1319 21.87C74.1319 22.41 74.1019 22.83 74.0119 23.28H61.3519C61.4719 26.16 62.8819 27.69 66.3319 27.69C69.4519 27.69 70.7419 26.67 70.7419 24.9V24.66H73.9819V24.93C73.9819 28.11 70.8619 30.3 66.4219 30.3ZM66.3019 17.34C63.0019 17.34 61.5619 18.81 61.3819 21.48H71.0719V21.42C71.0719 18.66 69.4819 17.34 66.3019 17.34ZM78.9586 35.1H76.8286V32.16H79.7386C81.0586 32.16 81.5986 31.8 82.0486 30.78L82.4086 30L75.0586 15.09H78.6886L82.4986 23.01L83.9686 26.58H84.2086L85.6186 22.98L89.1286 15.09H92.6986L84.9286 31.62C83.6986 34.29 82.0186 35.1 78.9586 35.1Z"
            className="fill-black dark:fill-white"
          />
        </svg>
      </a>
      <a href="https://openstatus.dev">
        <svg
          aria-label="OpenStatus"
          viewBox="0 0 171 30"
          className="inline h-6 fill-black dark:fill-white"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path d="M12.48 23.416C10.304 23.416 8.32 22.904 6.528 21.88C4.75733 20.8347 3.36 19.4267 2.336 17.656C1.312 15.8853 0.8 13.944 0.8 11.832C0.8 9.72 1.312 7.77867 2.336 6.008C3.36 4.216 4.75733 2.79733 6.528 1.752C8.32 0.706665 10.304 0.183998 12.48 0.183998C14.656 0.183998 16.6293 0.706665 18.4 1.752C20.1707 2.79733 21.5573 4.216 22.56 6.008C23.584 7.77867 24.096 9.72 24.096 11.832C24.096 13.944 23.584 15.8853 22.56 17.656C21.5573 19.4267 20.1707 20.8347 18.4 21.88C16.6293 22.904 14.656 23.416 12.48 23.416ZM5.44 11.832C5.44 13.1973 5.728 14.4453 6.304 15.576C6.88 16.7067 7.70133 17.6027 8.768 18.264C9.83467 18.9253 11.072 19.256 12.48 19.256C13.888 19.256 15.1147 18.9253 16.16 18.264C17.2267 17.6027 18.0373 16.7067 18.592 15.576C19.168 14.4453 19.456 13.1973 19.456 11.832C19.456 10.4667 19.168 9.21867 18.592 8.088C18.0373 6.936 17.2267 6.02933 16.16 5.368C15.1147 4.68533 13.888 4.344 12.48 4.344C11.072 4.344 9.83467 4.68533 8.768 5.368C7.70133 6.02933 6.88 6.936 6.304 8.088C5.728 9.21867 5.44 10.4667 5.44 11.832ZM26.3425 6.36H30.5985V9.048C31.0892 8.06667 31.7505 7.32 32.5825 6.808C33.4145 6.27467 34.5238 6.008 35.9105 6.008C37.4038 6.008 38.7798 6.40267 40.0385 7.192C41.2972 7.98133 42.2892 9.048 43.0145 10.392C43.7612 11.7147 44.1345 13.1653 44.1345 14.744C44.1345 16.3227 43.7612 17.7733 43.0145 19.096C42.2892 20.4187 41.2972 21.4747 40.0385 22.264C38.7798 23.032 37.4038 23.416 35.9105 23.416C34.5665 23.416 33.4678 23.1707 32.6145 22.68C31.7825 22.168 31.1318 21.4533 30.6625 20.536V29.4H26.3425V6.36ZM30.5345 14.744C30.5345 15.6187 30.7265 16.4187 31.1105 17.144C31.4945 17.8693 32.0385 18.4453 32.7425 18.872C33.4678 19.2987 34.2892 19.512 35.2065 19.512C36.1025 19.512 36.8918 19.2987 37.5745 18.872C38.2785 18.424 38.8225 17.8373 39.2065 17.112C39.6118 16.3653 39.8145 15.5653 39.8145 14.712C39.8145 13.8373 39.6225 13.0373 39.2385 12.312C38.8545 11.5867 38.3105 11.0107 37.6065 10.584C36.9025 10.136 36.1025 9.912 35.2065 9.912C34.2892 9.912 33.4678 10.136 32.7425 10.584C32.0385 11.0107 31.4945 11.5973 31.1105 12.344C30.7265 13.0693 30.5345 13.8693 30.5345 14.744ZM53.873 23.416C52.1877 23.416 50.6943 23.032 49.393 22.264C48.0917 21.4747 47.0783 20.4187 46.353 19.096C45.6277 17.7733 45.265 16.312 45.265 14.712C45.265 13.1333 45.6383 11.672 46.385 10.328C47.1317 8.984 48.1557 7.91733 49.457 7.128C50.7797 6.33867 52.2517 5.944 53.873 5.944C55.4943 5.944 56.945 6.33867 58.225 7.128C59.5263 7.91733 60.529 8.984 61.233 10.328C61.9583 11.6507 62.321 13.112 62.321 14.712C62.321 15.2453 62.2783 15.7573 62.193 16.248H49.745C50.001 17.2507 50.481 18.0613 51.185 18.68C51.9103 19.2773 52.8063 19.576 53.873 19.576C54.769 19.576 55.569 19.3733 56.273 18.968C56.977 18.5413 57.5317 17.9973 57.937 17.336L61.297 19.864C60.6143 20.9307 59.6117 21.7947 58.289 22.456C56.9663 23.096 55.4943 23.416 53.873 23.416ZM57.969 13.016C57.713 12.056 57.2117 11.256 56.465 10.616C55.7183 9.976 54.833 9.656 53.809 9.656C52.8063 9.656 51.9317 9.96533 51.185 10.584C50.4597 11.2027 49.9797 12.0133 49.745 13.016H57.969ZM64.2175 6.36H68.4735V8.792C69.3482 6.91467 71.0442 5.976 73.5615 5.976C74.7562 5.976 75.8335 6.264 76.7935 6.84C77.7535 7.39467 78.5108 8.19467 79.0655 9.24C79.6202 10.264 79.8975 11.4587 79.8975 12.824V23H75.5775V13.88C75.5775 12.4933 75.2575 11.4587 74.6175 10.776C73.9775 10.0933 73.1028 9.752 71.9935 9.752C71.0122 9.752 70.1908 10.104 69.5295 10.808C68.8682 11.4907 68.5375 12.5147 68.5375 13.88V23H64.2175V6.36ZM89.9273 23.416C88.0713 23.416 86.4073 23.032 84.9353 22.264C83.4846 21.4747 82.2899 20.248 81.3513 18.584L85.2233 16.12C85.7779 17.2293 86.4819 18.0613 87.3353 18.616C88.2099 19.1493 89.1593 19.416 90.1833 19.416C91.2073 19.416 92.0179 19.1813 92.6153 18.712C93.2339 18.2427 93.5433 17.624 93.5433 16.856C93.5433 16.152 93.3193 15.576 92.8713 15.128C92.4233 14.68 91.8473 14.328 91.1433 14.072C90.4606 13.7947 89.5539 13.5067 88.4233 13.208C86.6313 12.7387 85.2339 11.9813 84.2313 10.936C83.2499 9.89067 82.7593 8.54667 82.7593 6.904C82.7593 5.58133 83.0899 4.41867 83.7513 3.416C84.4126 2.392 85.3406 1.60267 86.5353 1.048C87.7299 0.493333 89.1059 0.216 90.6633 0.216C92.3486 0.216 93.7779 0.568 94.9513 1.272C96.1459 1.976 97.1806 3.01067 98.0553 4.376L94.2153 6.744C93.6606 5.848 93.0953 5.208 92.5193 4.824C91.9433 4.41867 91.2499 4.216 90.4392 4.216C89.5219 4.216 88.7753 4.44 88.1993 4.888C87.6233 5.336 87.3353 5.93333 87.3353 6.68C87.3353 7.42667 87.6233 7.992 88.1993 8.376C88.7753 8.73867 89.6713 9.112 90.8873 9.496C92.3806 9.96533 93.5753 10.4027 94.4713 10.808C95.3673 11.2133 96.1993 11.896 96.9673 12.856C97.7353 13.7947 98.1193 15.0427 98.1193 16.6C98.1193 17.944 97.7886 19.1387 97.1273 20.184C96.4659 21.208 95.5166 22.008 94.2793 22.584C93.0419 23.1387 91.5913 23.416 89.9273 23.416ZM106.084 23C104.399 23 103.129 22.584 102.276 21.752C101.423 20.92 100.996 19.6187 100.996 17.848V10.04H98.66V6.36H100.996V3L105.316 2.552V6.36H108.836V10.04H105.316V17.624C105.316 18.648 105.764 19.16 106.66 19.16H108.452V23H106.084ZM117.427 23.416C115.933 23.416 114.557 23.032 113.299 22.264C112.04 21.4747 111.037 20.4187 110.291 19.096C109.565 17.7733 109.203 16.3227 109.203 14.744C109.203 13.1653 109.565 11.7147 110.291 10.392C111.037 9.048 112.04 7.98133 113.299 7.192C114.557 6.40267 115.933 6.008 117.427 6.008C118.792 6.008 119.891 6.264 120.723 6.776C121.576 7.288 122.237 8.024 122.707 8.984V6.36H126.995V23H122.803V20.28C122.312 21.2827 121.64 22.0613 120.787 22.616C119.955 23.1493 118.835 23.416 117.427 23.416ZM113.523 14.712C113.523 15.5653 113.715 16.3653 114.099 17.112C114.504 17.8373 115.048 18.424 115.731 18.872C116.435 19.2987 117.235 19.512 118.131 19.512C119.048 19.512 119.859 19.2987 120.563 18.872C121.288 18.4453 121.843 17.8693 122.227 17.144C122.611 16.4187 122.803 15.6187 122.803 14.744C122.803 13.8693 122.611 13.0693 122.227 12.344C121.843 11.5973 121.288 11.0107 120.563 10.584C119.859 10.136 119.048 9.912 118.131 9.912C117.235 9.912 116.435 10.136 115.731 10.584C115.027 11.0107 114.483 11.5867 114.099 12.312C113.715 13.0373 113.523 13.8373 113.523 14.712ZM135.865 23C134.18 23 132.911 22.584 132.057 21.752C131.204 20.92 130.777 19.6187 130.777 17.848V10.04H128.441V6.36H130.777V3L135.097 2.552V6.36H138.617V10.04H135.097V17.624C135.097 18.648 135.545 19.16 136.441 19.16H138.233V23H135.865ZM146.237 23.384C145.043 23.384 143.965 23.1067 143.005 22.552C142.045 21.976 141.288 21.176 140.733 20.152C140.179 19.1067 139.901 17.9013 139.901 16.536V6.36H144.221V15.48C144.221 18.232 145.331 19.608 147.549 19.608C148.531 19.608 149.352 19.2667 150.013 18.584C150.675 17.88 151.005 16.8453 151.005 15.48V6.36H155.325V23H151.133V20.504C150.728 21.4853 150.131 22.2107 149.341 22.68C148.552 23.1493 147.517 23.384 146.237 23.384ZM163.57 23.416C160.775 23.416 158.471 22.4453 156.658 20.504L159.57 17.848C160.786 19.2133 162.087 19.896 163.474 19.896C164.199 19.896 164.764 19.736 165.17 19.416C165.575 19.096 165.778 18.68 165.778 18.168C165.778 17.6987 165.575 17.336 165.17 17.08C164.786 16.8027 163.975 16.5147 162.738 16.216C160.711 15.7253 159.346 15.0533 158.642 14.2C157.959 13.3467 157.618 12.2907 157.618 11.032C157.618 9.53867 158.172 8.32267 159.282 7.384C160.391 6.424 161.906 5.944 163.826 5.944C165.212 5.944 166.375 6.15733 167.314 6.584C168.274 7.01067 169.17 7.75733 170.002 8.824L166.866 11.224C166.119 10.0293 165.138 9.432 163.922 9.432C163.303 9.432 162.802 9.56 162.418 9.816C162.034 10.0507 161.842 10.4133 161.842 10.904C161.842 11.2453 161.98 11.544 162.258 11.8C162.556 12.0347 163.164 12.2693 164.082 12.504C166.364 13.1013 167.922 13.8373 168.754 14.712C169.607 15.5867 170.034 16.696 170.034 18.04C170.034 19.0427 169.746 19.96 169.17 20.792C168.615 21.6027 167.847 22.2427 166.866 22.712C165.884 23.1813 164.786 23.416 163.57 23.416Z" />
        </svg>
      </a>
      <a href="https://midday.ai">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 102 30"
          className="inline h-8 fill-black md:h-10 dark:fill-white"
          fill="none"
          aria-label="Midday.ai"
        >
          <path
            fill="currentColor"
            fillRule="evenodd"
            d="M14.347 0a14.931 14.931 0 0 0-6.282 1.68l6.282 10.88V0Zm0 17.443L8.067 28.32a14.933 14.933 0 0 0 6.28 1.68V17.443ZM15.652 30V17.432l6.285 10.887A14.932 14.932 0 0 1 15.652 30Zm0-17.43V0c2.26.097 4.392.693 6.287 1.682l-6.287 10.889ZM2.336 23.068l10.884-6.284-6.284 10.884a15.093 15.093 0 0 1-4.6-4.6Zm25.33-16.132-10.88 6.282 6.282-10.88a15.094 15.094 0 0 1 4.598 4.598ZM2.335 6.934a15.094 15.094 0 0 1 4.6-4.6l6.284 10.884L2.335 6.934Zm-.654 1.13A14.931 14.931 0 0 0 0 14.35h12.568L1.681 8.064Zm0 13.873a14.932 14.932 0 0 1-1.68-6.282h12.562L1.682 21.938Zm15.754-7.587H30a14.93 14.93 0 0 0-1.68-6.285L17.435 14.35Zm10.884 7.586-10.878-6.28H30a14.932 14.932 0 0 1-1.68 6.28Zm-11.533-5.151 6.281 10.88a15.092 15.092 0 0 0 4.598-4.599l-10.88-6.281Z"
            clipRule="evenodd"
          />
          <path
            fill="currentColor"
            d="M92.34 11.912h1.637l2.995 8.223 2.884-8.223h1.619l-4 11.107c-.372 1.06-1.08 1.544-2.196 1.544h-1.172v-1.358h1.024c.502 0 .8-.186.986-.707l.353-.912h-.52l-3.61-9.674ZM82.744 14.814c.39-1.916 1.916-3.126 4.018-3.126 2.549 0 3.963 1.489 3.963 4.13v3.964c0 .446.186.632.614.632h.39v1.358h-.65c-1.005 0-1.88-.335-1.861-1.544-.428.93-1.544 1.767-3.107 1.767-1.954 0-3.535-1.041-3.535-2.79 0-2.028 1.544-2.55 3.702-2.977l2.921-.558c-.018-1.712-.818-2.53-2.437-2.53-1.265 0-2.102.65-2.4 1.804l-1.618-.13Zm1.432 4.39c0 .8.689 1.452 2.14 1.433 1.637 0 2.92-1.153 2.92-3.442v-.167l-2.362.41c-1.47.26-2.698.371-2.698 1.767ZM80.129 8.563v13.21h-1.377l-.056-1.452c-.558 1.042-1.618 1.675-3.144 1.675-2.847 0-4.168-2.419-4.168-5.154s1.321-5.153 4.168-5.153c1.451 0 2.493.558 3.051 1.562V8.563h1.526Zm-7.145 8.28c0 1.915.819 3.701 2.884 3.701 2.028 0 2.865-1.823 2.865-3.702 0-1.953-.837-3.758-2.865-3.758-2.065 0-2.884 1.786-2.884 3.758ZM68.936 8.563v13.21H67.56l-.056-1.452c-.558 1.042-1.619 1.675-3.144 1.675-2.847 0-4.168-2.419-4.168-5.154s1.321-5.153 4.168-5.153c1.45 0 2.493.558 3.05 1.562V8.563h1.526Zm-7.144 8.28c0 1.915.819 3.701 2.884 3.701 2.028 0 2.865-1.823 2.865-3.702 0-1.953-.837-3.758-2.865-3.758-2.065 0-2.884 1.786-2.884 3.758ZM56.212 11.912h1.525v9.86h-1.525v-9.86Zm-.037-1.544V8.6h1.6v1.768h-1.6ZM40.224 11.912h1.395l.056 1.674c.446-1.21 1.47-1.898 2.846-1.898 1.414 0 2.438.763 2.865 2.084.428-1.34 1.47-2.084 3.014-2.084 1.973 0 3.126 1.377 3.126 3.74v6.344H52v-5.897c0-1.805-.707-2.828-1.916-2.828-1.544 0-2.437 1.041-2.437 2.846v5.88H46.12v-5.899c0-1.767-.725-2.827-1.916-2.827-1.526 0-2.456 1.079-2.456 2.827v5.898h-1.525v-9.86Z"
          />
        </svg>
      </a>
      <a href="https://openpanel.dev" className="flex items-center gap-2">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 278 278"
          fill="none"
          className="inline h-8 fill-black md:h-10 dark:fill-white"
          role="presentation"
        >
          <rect width="278" height="278" rx="20" fill="#2664EB" />
          <path
            d="M148.959 203H128.873C128.291 203 128 202.698 128 202.095L128.349 74.7242C128.349 74.2414 128.582 74 129.048 74H163.456C174.402 74 183.048 77.4702 189.394 84.4105C195.798 91.2905 199 100.675 199 112.564C199 121.255 197.341 128.829 194.022 135.286C190.645 141.684 186.279 146.632 180.923 150.133C175.566 153.633 169.744 155.383 163.456 155.383H149.833V202.095C149.833 202.698 149.542 203 148.959 203ZM163.456 95.9979L149.833 96.179V132.933H163.456C167.241 132.933 170.53 131.062 173.325 127.32C176.119 123.518 177.517 118.599 177.517 112.564C177.517 107.736 176.265 103.783 173.761 100.705C171.258 97.567 167.823 95.9979 163.456 95.9979Z"
            fill="white"
            fillOpacity="0.9"
          />
          <path
            d="M114.47 203C108.074 203 102.177 201.36 96.7791 198.079C91.4395 194.798 87.1267 190.434 83.8408 184.986C80.6136 179.479 79 173.445 79 166.884L79.176 109.853C79.176 103.174 80.7896 97.1696 84.0169 91.8386C87.1854 86.4489 91.4688 82.143 96.8671 78.921C102.265 75.6403 108.133 74 114.47 74C121.042 74 126.939 75.611 132.161 78.8331C137.442 82.0552 141.667 86.3903 144.835 91.8386C148.063 97.2282 149.676 103.233 149.676 109.853L149.852 166.884C149.852 173.445 148.268 179.45 145.099 184.898C141.872 190.405 137.589 194.798 132.249 198.079C126.91 201.36 120.983 203 114.47 203ZM114.47 181.295C118.108 181.295 121.277 179.83 123.976 176.901C126.675 173.913 128.025 170.574 128.025 166.884L127.848 109.853C127.848 105.869 126.587 102.501 124.064 99.7473C121.541 96.9939 118.343 95.6172 114.47 95.6172C110.774 95.6172 107.605 96.9646 104.965 99.6594C102.324 102.354 101.004 105.752 101.004 109.853V166.884C101.004 170.809 102.324 174.206 104.965 177.077C107.605 179.889 110.774 181.295 114.47 181.295Z"
            fill="white"
            fillOpacity="0.9"
          />
        </svg>
        <span className="text-lg font-medium">openpanel.dev</span>
      </a>
      <a href="https://www.liminity.se/">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 703 70"
          className="inline h-6 fill-black dark:fill-white"
          aria-label="Liminity"
        >
          <path d="m176.3 56.1h27.7v6.2h-34.5v-55.4h6.8z"></path>
          <path d="m249.6 62.3h-6.8v-55.4h6.8z"></path>
          <path d="m352.4 62.3h-6.7v-40.9l-20.8 40.9h-4.8l-20.8-40.9v40.9h-6.8v-55.4h6.8l23.2 45.3 23.1-45.3h6.8z"></path>
          <path d="m402.1 62.3h-6.8v-55.4h6.8z"></path>
          <path d="m486.8 62.3h-6.4l-28.6-42.6v42.6h-6.8v-55.4h6.3l28.8 42.7v-42.7h6.7z"></path>
          <path d="m536.5 62.3h-6.8v-55.4h6.8z"></path>
          <path d="m621.9 13h-20.6v49.3h-6.8v-49.3h-20.5v-6.1h47.9z"></path>
          <path d="m681.8 40.1v22.2h-6.8v-22.2l-21-33.2h8l16.5 25.8 16.2-25.8h8z"></path>
          <path d="m94.1 0.7l-59.3 59.3-25-25 25.6-25.6 21.7 21.5 4.5-4.5-26.2-26.1-34.7 34.7 34.1 34.1 59.3-59.3 24.7 24.7-23.5 25.5-23-23-4.6 4.5 27.8 27.7 32.2-34.9z"></path>
        </svg>
      </a>
      <a href="https://databuddy.cc?utm_source=nuqs">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 400 67"
          className="inline h-7.5 fill-black dark:fill-white"
          aria-label="Databuddy"
        >
          <path
            fillRule="evenodd"
            clipRule="evenodd"
            d="M22.2645 22.2051H33.3966V33.3079H22.2645V22.2051ZM33.3966 33.3079H44.5286V44.4107H33.3966V33.3079Z"
          />
          <path d="M66.7929 11.1035H55.6609V55.515H66.7929V11.1035Z" />
          <path
            fillRule="evenodd"
            clipRule="evenodd"
            d="M0 0H55.6608V11.1028H11.1321V55.5143H55.6608V66.617H0V0Z"
          />
          <path d="M90.7033 16.1753C102.674 16.1753 109.348 22.9373 109.348 34.9822C109.348 46.9739 102.78 53.6832 91.0211 53.6832H78.3088V16.1753H90.7033ZM84.9828 47.8193H90.7033C98.6484 47.8193 102.515 43.593 102.515 34.9822C102.515 26.2126 98.6484 22.0392 90.7033 22.0392H84.9828V47.8193Z" />
          <path d="M113.084 53.6832L126.644 16.1753H134.589L148.149 53.6832H141.263L138.138 44.5969H123.095L119.97 53.6832H113.084ZM125.108 38.8386H136.125L130.616 22.7788L125.108 38.8386Z" />
          <path d="M176.819 16.1753V22.0392H165.431V53.6832H158.757V22.0392H147.316V16.1753H176.819Z" />
          <path d="M176.058 53.6832L189.617 16.1753H197.562L211.122 53.6832H204.237L201.111 44.5969H186.068L182.943 53.6832H176.058ZM188.081 38.8386H199.098L193.59 22.7788L188.081 38.8386Z" />
          <path d="M217.447 53.6832V16.1753H230.847C240.541 16.1753 245.359 19.5035 245.359 26.5825C245.359 30.9672 242.657 33.7142 238.104 34.2425C243.717 34.8237 246.948 37.9933 246.948 43.0647C246.948 49.9324 242.022 53.6832 232.966 53.6832H217.447ZM224.119 47.9249H233.071C237.468 47.9249 240.117 46.1288 240.117 42.6422C240.117 39.1554 237.468 37.2536 233.071 37.2536H224.119V47.9249ZM224.119 31.918H231.217C235.826 31.918 238.528 30.2276 238.528 26.9523C238.528 23.5184 235.985 21.8807 231.217 21.8807H224.119V31.918Z" />
          <path d="M284.945 40.3178C284.945 49.0343 279.171 54.5286 269.955 54.5286C260.738 54.5286 255.019 49.0343 255.019 40.3178V16.1226H261.692V40.3178C261.692 45.7062 264.711 48.6647 269.955 48.6647C275.251 48.6647 278.27 45.7062 278.27 40.3178V16.1226H284.945V40.3178Z" />
          <path d="M306.778 16.1753C318.75 16.1753 325.425 22.9373 325.425 34.9822C325.425 46.9739 318.856 53.6832 307.096 53.6832H294.385V16.1753H306.778ZM301.059 47.8193H306.778C314.724 47.8193 318.591 43.593 318.591 34.9822C318.591 26.2126 314.724 22.0392 306.778 22.0392H301.059V47.8193Z" />
          <path d="M345.405 16.1753C357.375 16.1753 364.049 22.9373 364.049 34.9822C364.049 46.9739 357.481 53.6832 345.723 53.6832H333.009V16.1753H345.405ZM339.684 47.8193H345.405C353.349 47.8193 357.216 43.593 357.216 34.9822C357.216 26.2126 353.349 22.0392 345.405 22.0392H339.684V47.8193Z" />
          <path d="M367.32 16.1753H374.681L383.686 32.235L392.692 16.1753H400L387.024 38.7858V53.6832H380.349V38.7858L367.32 16.1753Z" />
        </svg>
      </a>
    </p>
  )
}

async function DependentsLeaderboard() {
  let dependents: Dependent[] = []
  try {
    dependents = await fetchDependents()
  } catch (error) {
    console.error(error)
    return <div className="text-red-500">{String(error)}</div>
  }
  return (
    <div className="flex flex-wrap justify-center gap-1.5">
      {dependents.map(dep => (
        <a
          key={dep.owner + dep.name}
          href={`https://github.com/${dep.owner}/${dep.name}`}
          className="relative h-8 w-8 rounded-full"
        >
          <img
            src={upscaleGitHubAvatar(dep.avatarURL, 64)}
            alt={dep.owner + '/' + dep.name}
            className="rounded-full"
            loading="lazy"
            width={64}
            height={64}
          />
          <span
            className={cn(
              'border-background absolute right-0 bottom-0 h-2.5 w-2.5 rounded-full border-2',
              dep.pkg === 'nuqs' ? 'bg-green-500' : 'bg-zinc-500'
            )}
            aria-label={`Using ${dep.pkg}`}
          />
        </a>
      ))}
    </div>
  )
}

function upscaleGitHubAvatar(originalURL: string, size: number) {
  const url = new URL(originalURL)
  url.searchParams.set('s', size.toFixed())
  return url.toString()
}
